home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-23 | 1.1 KB | 30 lines | [TEXT/MPS ] |
- # By Brandon S. Allbery
- #
- # Usage: $cwd = &getcwd;
-
- sub getcwd
- {
- local($dotdots, $cwd, @pst, @cst, $dir, @tst);
-
- unless (@cst = stat('.'))
- {
- warn "stat(.): $!";
- return '';
- }
- $cwd = '';
- do
- {
- $dotdots .= '/' if $dotdots;
- $dotdots .= '..';
- @pst = @cst;
- unless (opendir(getcwd'PARENT, $dotdots)) #'))
- {
- warn "opendir($dotdots): $!";
- return '';
- }
- unless (@cst = stat($dotdots))
- {
- warn "stat($dotdots): $!";
- closedir(getcwd'PARENT); #');
- return '';